package com.xmscltd.scms.base.service;

import com.jfinal.plugin.activerecord.Model;
import com.jfinal.plugin.activerecord.Page;
import com.xmscltd.scms.base.model.Msg;

import java.util.List;

public interface MsgService  {


    /**
     * 查找消息列表
     *
     * @param id
     * @return
     */
    public List<Msg> findByReceiverId(int id);

    /**
     * 根据发送者查找消息列表
     *
     * @param senderName 发送者名字
     * @param id 接收者id
     * @return
     */
    public List<Msg> findBySender(String senderName, Object id);

    /**
     * 消息列表泛查
     *
     * @param keyWord 关键词
     * @param id 接收者id
     * @return
     */
    public List<Msg> findByKeyWord(String keyWord, Object id);

    /**
     * find model by primary key
     *
     * @param id
     * @return
     */
    public Msg findById(Object id);


    /**
     * find all model
     *
     * @return all <Msg
     */
    public List<Msg> findAll();


    /**
     * delete model by primary key
     *
     * @param id
     * @return success
     */
    public boolean deleteById(Object id);


    /**
     * delete model
     *
     * @param model
     * @return
     */
    public boolean delete(Msg model);


    /**
     * save model to database
     *
     * @param model
     * @return
     */
    public boolean save(Msg model);


    /**
     * save or update model
     *
     * @param model
     * @return if save or update success
     */
    public boolean saveOrUpdate(Msg model);


    /**
     * update data model
     *
     * @param model
     * @return
     */
    public boolean update(Msg model);


    public void join(Page<? extends Model> page, String joinOnField);
    public void join(Page<? extends Model> page, String joinOnField, String[] attrs);
    public void join(Page<? extends Model> page, String joinOnField, String joinName);
    public void join(Page<? extends Model> page, String joinOnField, String joinName, String[] attrs);
    public void join(List<? extends Model> models, String joinOnField);
    public void join(List<? extends Model> models, String joinOnField, String[] attrs);
    public void join(List<? extends Model> models, String joinOnField, String joinName);
    public void join(List<? extends Model> models, String joinOnField, String joinName, String[] attrs);
    public void join(Model model, String joinOnField);
    public void join(Model model, String joinOnField, String[] attrs);
    public void join(Model model, String joinOnField, String joinName);
    public void join(Model model, String joinOnField, String joinName, String[] attrs);

    public void keep(Model model, String... attrs);
    public void keep(List<? extends Model> models, String... attrs);
}